from django.db import models
from django.contrib.auth.models import User

# Create your models here.


class Lesson_class(models.Model):
    name = models.CharField(max_length=50)
    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = '课程类别'

class Lesson(models.Model):
    name = models.CharField(max_length=50)
    belong_less_class = models.ForeignKey(to=Lesson_class)
    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = '课程'

class Subject(models.Model):
    name = models.CharField(max_length=50)
    time = models.DateField(auto_now_add=True)
    teacher = models.ForeignKey(to=User, null=True)
    belong_less = models.ForeignKey(to=Lesson_class)
    image = models.FileField(upload_to='image', null=True, blank=True)
    video = models.FileField(upload_to='video', null=True, blank=True)
    file = models.FileField(upload_to='file', null=True, blank=True)
    comment = models.TextField()
    def __str__(self):
        return self.name
    class Meta:
        verbose_name_plural = '课件'
